﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
#if !NETCOREAPP
using System.Web;
using System.Web.Mvc;
using System.Web.WebPages;
    using System.Web.Mvc.Html;

#endif

#if NETCOREAPP
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.AspNetCore.Mvc.Rendering;
using Kugar.Core.Web;
#endif
using Kugar.MVC.MobileUI.WeUI.Helpers;

namespace Kugar.MVC.MobileUI.WeUI.PageControls.PageCommons
{
    public class PageCommon_LoadMore : ControlBase
    {
        private string _script = "";
        private string _tips = "正在加载";

        public PageCommon_LoadMore(ViewContext viewContext) : base(viewContext)
        {
            this.Css("weui-loadmore");
        }

        public PageCommon_LoadMore OnTriggerLoad(string script)
        {
            _script = script;

            return this;
        }

        public PageCommon_LoadMore Tips(string text)
        {
            _tips = text;

            return this;
        }

        public override MvcHtmlString Render()
        {
            /*
             <div class="weui-loadmore">
               <i class="weui-loading"></i>
               <span class="weui-loadmore__tips">正在加载</span>
              </div>
             */

            ViewContext.Writer.WriteLine($"<div {_attrs} data-ontrigger='{_script}'><i class=\"weui-loading\"></i><span class=\"weui-loadmore__tips\">{_tips}</span></div>");

            return MvcHtmlString.Empty;
        }
    }
}